<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

    <!-- Define base URL as parameter -->
    <xsl:param name="base_url">https://www.imixs.org/doc</xsl:param>

    <!-- Output settings -->
    <xsl:output method="xml" indent="yes" encoding="UTF-8" />

    <!-- Root template -->
    <xsl:template match="/">
        <urlset>
            <!-- static root level pages -->
            <url>
                <loc>https://www.imixs.org/index.html</loc>
                <priority>1.0</priority>
                <changefreq>monthly</changefreq>
            </url>
            <url>
                <loc>https://www.imixs.org/sub_community.html</loc>
                <priority>0.9</priority>
                <changefreq>monthly</changefreq>
            </url>
            <url>
                <loc>https://www.imixs.org/sub_jee.html</loc>
                <priority>0.9</priority>
                <changefreq>monthly</changefreq>
            </url>
            <url>
                <loc>https://www.imixs.org/sub_jsf.html</loc>
                <priority>0.9</priority>
                <changefreq>monthly</changefreq>
            </url>
            <url>
                <loc>https://www.imixs.org/sub_microservice.html</loc>
                <priority>0.9</priority>
                <changefreq>monthly</changefreq>
            </url>
            <url>
                <loc>https://www.imixs.org/sub_modeler.html</loc>
                <priority>0.9</priority>
                <changefreq>monthly</changefreq>
            </url>
            <url>
                <loc>https://www.imixs.org/sub_security.html</loc>
                <priority>0.9</priority>
                <changefreq>monthly</changefreq>
            </url>

            <!-- pages generated by maven site plugin from site.xml -->
            <xsl:apply-templates select="//item[not(@target='_blank')]" />
        </urlset>
    </xsl:template>

    <xsl:template match="item">
        <xsl:if test="@href and not(contains(@href, 'apidocs'))">
            <url>
                <loc>
                    <xsl:value-of select="$base_url" />
                    <xsl:if test="not(starts-with(@href, 'http'))">
                        <xsl:text>/</xsl:text>
                    </xsl:if>
                    <xsl:value-of select="@href" />
                </loc>
                <priority>
                    <xsl:choose>
                        <xsl:when test="parent::menu">0.8</xsl:when>
                        <xsl:when test="parent::item/parent::menu">0.7</xsl:when>
                        <xsl:otherwise>0.6</xsl:otherwise>
                    </xsl:choose>
                </priority>
                <changefreq>weekly</changefreq>
            </url>
        </xsl:if>
        <xsl:apply-templates
            select="item" />
    </xsl:template>
</xsl:stylesheet>